Skip to content

fix(datasource-cosmos): increase maxConditions default to 1000#212

Merged
PMerlet merged 3 commits into
mainfrom
fix/increase-max-conditions-limit
Apr 9, 2026
Merged

fix(datasource-cosmos): increase maxConditions default to 1000#212
PMerlet merged 3 commits into
mainfrom
fix/increase-max-conditions-limit

Conversation

@PMerlet
Copy link
Copy Markdown
Member

@PMerlet PMerlet commented Apr 9, 2026

Summary

  • Raises the default maxConditions from 100 to 1000 in QueryValidator, fixing chart queries that fail with QueryValidationError: Condition tree exceeds maximum of 100 conditions when using daily time buckets over long date ranges
  • Exposes maxConditions as a configurable option in createCosmosDataSource for users who need higher limits
  • Threads the option through CosmosDataSourceCosmosCollectionQueryConverterQueryValidator
  • Fixes HTTP status code: QueryValidationError now extends ValidationError from datasource-toolkit, so the agent returns 400 Bad Request instead of 500 Internal Server Error when the condition limit is hit

Context

Forest Admin charts with daily granularity generate one condition per time bucket. A year of daily data = 365 conditions, and adding 2-3 filters pushes it over 1000. The previous default of 100 broke charts for any date range beyond ~3 months.

Additionally, QueryValidationError extended plain Error, causing the agent's error handler to fall through to the default 500 status code. A query validation issue is a client error (400), not a server error (500).

Test plan

  • 23 new tests in max-conditions.test.ts covering:
    • Default of 1000 at QueryValidator level (boundary tests at 1000/1001)
    • Custom maxConditions passthrough via QueryConverter, CosmosCollection, and CosmosDataSource
    • Realistic chart scenarios (daily chart over 1 year, 3 filters × 365 days, weekly over 2 years)
    • QueryValidationError is instanceof ValidationError and passes BusinessError.isOfType check
  • All 128 existing tests still pass

🤖 Generated with Claude Code

Note

Increase maxConditions default from 100 to 1000 in Cosmos datasource query validator

  • Raises the default maxConditions limit in QueryValidator from 100 to 1000, fixing failures for queries with large condition trees (e.g. chart filters).
  • Adds a maxConditions option to createCosmosDataSource, CosmosDataSource, and CosmosCollection so callers can override the limit.
  • Changes QueryValidationError to extend ValidationError from @forestadmin/datasource-toolkit, so validation failures return HTTP 400 instead of 500.

Macroscope summarized 4cf51be.

PMerlet and others added 3 commits April 9, 2026 14:28
Charts with daily time buckets over long date ranges generate one condition
per bucket, easily exceeding the previous 100-condition limit. A year of
daily data with 2-3 filters produces ~1100 conditions.

Also exposes maxConditions as a configurable option in createCosmosDataSource
for users who need even higher limits.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…Error

QueryValidationError now extends ValidationError from datasource-toolkit
so the agent error handler maps it to 400 (Bad Request) instead of 500
(Internal Server Error). A query with too many conditions is a client
validation issue, not a server error.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@PMerlet PMerlet merged commit 96df1f5 into main Apr 9, 2026
2 checks passed
@PMerlet PMerlet deleted the fix/increase-max-conditions-limit branch April 9, 2026 12:54
forest-bot added a commit that referenced this pull request Apr 9, 2026
# [1.9.0](https://github.com/ForestAdmin/forestadmin-experimental/compare/datasource-cosmos@1.8.3...datasource-cosmos@1.9.0) (2026-04-09)

### Bug Fixes

* **datasource-cosmos:** increase maxConditions default to 1000 ([#212](#212)) ([96df1f5](96df1f5))

### Features

* **api chart:** allow customizing api chart with query or body parameters ([#211](#211)) ([6d3eb65](6d3eb65))
forest-bot added a commit that referenced this pull request Apr 24, 2026
# [1.12.0](https://github.com/ForestAdmin/forestadmin-experimental/compare/datasource-rpc@1.11.0...datasource-rpc@1.12.0) (2026-04-24)

### Bug Fixes

* allow aggregation by date ([#208](#208)) ([4622350](4622350))
* **datasource-cosmos:** increase maxConditions default to 1000 ([#212](#212)) ([96df1f5](96df1f5))
* fix aggregation when using a reserved keyword ([#207](#207)) ([7200f0b](7200f0b))
* **rpc agent:** release ([8f532a0](8f532a0))
* **rpc datasource:** fix introspection parsing ([b3978a1](b3978a1))
* use Cosmos DB compatible functions for date aggregation ([#209](#209)) ([f4be4e2](f4be4e2))

### Features

* **api chart:** allow customizing api chart with query or body parameters ([#211](#211)) ([6d3eb65](6d3eb65))

### Performance Improvements

* rollup Week/Quarter from Day-level queries ([#210](#210)) ([9528843](9528843))
forest-bot added a commit that referenced this pull request May 5, 2026
## [2.9.1](https://github.com/ForestAdmin/forestadmin-experimental/compare/rpc-agent@2.9.0...rpc-agent@2.9.1) (2026-05-05)

### Bug Fixes

* **datasource-cosmos:** increase maxConditions default to 1000 ([#212](#212)) ([96df1f5](96df1f5))
* **rpc agent:** use schema path option ([#215](#215)) ([4c700ec](4c700ec))
* **rpc datasource:** fix introspection parsing ([b3978a1](b3978a1))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant